﻿namespace EFS.RC.SupervisorCentral.Controls.Agents
{
	/// <summary>
	/// Interaction logic for ContactListItem.xaml
	/// </summary>
	public partial class ContactListItemTalking : ContactListItem
	{
		public ContactListItemTalking()
		{
			InitializeComponent();

			// ignore in design tool
			if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
			{
				// set icons
				buttonListen.ImageNormal = EFS.Common.UI.Resources.ImageSource.Cache.GetSource("Icon_AgentsListenNormalEnabled");
				buttonListen.ImageDisabled = EFS.Common.UI.Resources.ImageSource.Cache.GetSource("Icon_AgentsListenNormalDisabled");
				buttonListen.ImageHot = EFS.Common.UI.Resources.ImageSource.Cache.GetSource("Icon_AgentsListenHot");

				// set icons
				buttonRemoveFromACD.ImageNormal = EFS.Common.UI.Resources.ImageSource.Cache.GetSource("Icon_AgentACDRemoveNormal");
				buttonRemoveFromACD.ImageDisabled = EFS.Common.UI.Resources.ImageSource.Cache.GetSource("Icon_AgentACDRemoveDisabled");
				buttonRemoveFromACD.ImageHot = EFS.Common.UI.Resources.ImageSource.Cache.GetSource("Icon_AgentACDRemoveHot");

				// set events
				buttonListen.Click += new System.Windows.RoutedEventHandler(buttonListen_Click);
				buttonRemoveFromACD.Click += new System.Windows.RoutedEventHandler(buttonRemoveFromACD_Click);
			}
		}

		#region Properties
		/// Property CustomContactListItem: Get
		protected override Microsoft.Lync.Controls.CustomContactListItem LyncCustomContactListItem
		{
			get
			{
				return controlCustomContactListItem;
			}
		}
		#endregion

		public override void Update()
		{
			// call base
			base.Update();

			// get status
			EFS.RC.CC.Messages.Agents.Status agentStatus = AgentStatus;

			// update
			controlConvLength.LengthTicks = agentStatus.ConversationInfo.Length;
			textBlockOnHold.Text = agentStatus.ConversationInfo.IsOnHold ? "Yes" : "No";
			textBlockMusic.Text = agentStatus.ConversationInfo.IsMusicOn ? "On" : "Off";
			textBlockSupervised.Text = (agentStatus.ConversationInfo.Monitoring != EFS.RC.CC.Messages.Communicator.Lync.Conversation.Info.MonitoringStatus.None) ? "Yes" : "No";

			// update skill
			EFS.RC.CC.Messages.Agents.Skills.Skill skill = AgentStatus.GetSkill(RequiredSkillId);
			if (null != skill)
			{
				controlSkilledColor.SkilledValue = skill.Value;
			}
		}

		#region Events
		/// Listen
		private void buttonListen_Click(object sender, System.Windows.RoutedEventArgs e)
		{
			OnButtonClicked(e, eButtonType.Listen, Source, ACD);
		}

		/// Remove from ACD
		private void buttonRemoveFromACD_Click(object sender, System.Windows.RoutedEventArgs e)
		{
			OnButtonClicked(e, eButtonType.RemoveFromACD, Source, ACD);
		}
		#endregion
	}

}